package com.ym.medical.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ym.core.utils.tkmybatis.BaseSVImpl;
import com.ym.medical.dao.LabelsDao;
import com.ym.medical.domain.entity.LabelsEntity;
import com.ym.medical.domain.param.LabelsParam;
import com.ym.medical.domain.vo.LabelsVo;
import com.ym.medical.service.ILabelsSV;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class LabelsSVImpl extends BaseSVImpl<LabelsEntity, LabelsDao> implements ILabelsSV {

	@Override
	public long save(LabelsEntity labels) {
		this.insert(labels);
		return labels.getId();
	}

	@Override
	public LabelsEntity findById(long labelsId) {
		return this.selectById(labelsId);
	}

	@Override
	public LabelsEntity findByModel(LabelsParam labelsModel) {
		List<LabelsEntity> labelss = list(labelsModel);
		return labelss.isEmpty() ? null : labelss.get(0);
	}

	@Override
	public List<LabelsEntity> list(LabelsParam labelsModel) {
		return this.selectList(labelsModel.covert());
	}

	@Override
	public List<LabelsVo> listLabels(LabelsParam model) {
		return mapper.listLabels(model);
	}
	@Override
	public PageInfo<LabelsVo> listPageCustomer(String deptName, String diseaseName, int pageNo, int limit) {
		PageHelper.startPage(pageNo, limit);
		List<LabelsVo> labels = mapper.selectByModelCustomer(deptName, diseaseName);
		return new PageInfo<>(labels);
	}

}
